import request from './request'



const userSer = '/?ser=user';
const companyJobSer = '/?ser=companyJob'
const transSer = '/?ser=transmission'
const comSer ='/?ser=community'
//登录
export function login(data){
  return request({
    url:'/adminLogin/?ser=user',
    method:'post',
    params:{
        adminName:data.adminName,
        password:data.password,
        captcha:data.captcha,
    }
  })
}

//退出登录
export function logout(){
  return request({
    url:'/admin/logout'+userSer,
  })
}

//管理员列表
export function getAdminList(keywords,currentPage,pageSize){
  return request({
    url:'/admin/adminList'+userSer,
    params:{
      keywords,
      currentPage,
      pageSize
    }
  })
}
//删除管理员
export function delAdmin(adminId){
  return request({
    url:'/admin/delAdmin'+userSer,
    method:'delete',
    params:{
      adminId
    },
  })
}
//启用禁用
export function enableDisable(adminId){
  return request({
    url:'/admin/enableDisable'+userSer,
    method:'put',
    params:{
      adminId
    },
  })
}
//用户注销
export function logoutUser(password){
  return request({
    url:'/admin/logoutUser'+userSer,
    method:'delete',
    params:{
      password
    },
  })
}
//添加管理员
export function addAdmin(adminForm){
  return request({
    url:'/admin/addAdmin'+userSer,
    method:'post',
    params:{
      adminName:adminForm.adminName,
      password:adminForm.password,
      realName: adminForm.realName,
      tel:adminForm.tel,
      state:adminForm.state
    },
  })
}
//获取个人信息
export function getPersonInfo(adminName){
  return request({
    url:'/admin/personInfo'+userSer,
    params:{
      adminName
    },
  })
}
//修改个人信息
export function updatePersonInfo(infoForm){
  return request({
    url:'/admin/updatePersonInfo'+userSer,
    method:'post',
    params:{
      adminName:infoForm.adminName,
      sex:infoForm.sex,
      birthday: infoForm.birthday,
      tel:infoForm.tel,
      email:infoForm.email,
      address:infoForm.address
    },
  })
}
//重置密码
export function resetPwd(adminName){
  return request({
    url:'/admin/resetPwd'+userSer,
    method:'put',
    params:{
      adminName
    },
  })
}
//获取用户列表
export function getUserList(userType,keywords,currentPage,pageSize){
  return request({
    url:'/user/userList'+userSer,
    params:{
      userType,keywords,currentPage,pageSize
    },
  })
}
//获取企业认证用户列表
export function getAuthUserList(keywords,currentPage,pageSize,hasAuth){
  return request({
    url:'/user/authUserList'+userSer,
    params:{
      keywords,currentPage,pageSize,hasAuth
    },
  })
}
//删除用户
export function delUser(userId){
  return request({
    url:'/user/delUser'+userSer,
    method:'delete',
    params:{
      userId
    },
  })
}
//启用禁用用户
export function enableDisableUser(userId){
  return request({
    url:'/user/enableDisableUser'+userSer,
    method:'put',
    params:{
      userId
    },
  })
}



//获取企业列表
export function getCompanyList(keywords,currentPage,pageSize,hasAuth){
  return request({
    url:'/company/companyList'+companyJobSer,
    params:{
      keywords,currentPage,pageSize,hasAuth
    },
  })
}
//删除企业
export function delCompany(companyId){
  return request({
    url:'/company/delCompany'+companyJobSer,
    method:'delete',
    params:{
      companyId
    },
  })
}



//获取职位列表
export function getJobList(keywords,currentPage,pageSize){
  return request({
    url:'/job/jobList'+companyJobSer,
    params:{
      keywords,currentPage,pageSize
    },
  })
}
//获取简历模板列表
export function getRTList(keywords,currentPage,pageSize){
  return request({
    url:'/resumeTemplate/resumeTemplateList'+transSer,
    params:{
      keywords,currentPage,pageSize
    },
  })
}
//上架下架职位
export function shelveJob(jobId){
  return request({
    url:'/job/shelveJob'+companyJobSer,
    method:'put',
    params:{
      jobId
    },
  })
}
//上架下架简历模板
export function shelveRT(resumeTemplateId){
  return request({
    url:'/resumeTemplate/shelveResumeTemplate'+transSer,
    method:'put',
    params:{
      resumeTemplateId
    },
  })
}
//删除职位
export function delJob(jobId){
  return request({
    url:'/job/delJob'+companyJobSer,
    method:'put',
    params:{
      jobId
    },
  })
}
//删除职位
export function delRT(resumeTemplateId){
  return request({
    url:'/resumeTemplate/delResumeTemplate'+transSer,
    method:'put',
    params:{
      resumeTemplateId
    },
  })
}

//编辑模板
export function editResumeTemplate(resumeTemplateId,name,pay){
  return request({
    url:'/resumeTemplate/editResumeTemplate'+transSer,
    method:'put',
    params:{
      resumeTemplateId,name,pay
    },
  })
}
//密码修改
export function pwdChange(data){
  return request({
    url:'/admin/pwdChange'+userSer,
    method:'put',
    params:{
      adminName:localStorage.getItem("admin_adminName"),
      password:data.password,
      newPassword:data.newPassword,
    }
  })
}

//获取直播列表
export function getLiveList(keywords,currentPage,pageSize){
  return request({
    url:'/live/liveList'+transSer,
    params:{
      keywords,currentPage,pageSize
    },
  })
}
//删除直播
export function delLive(liveId){
  return request({
    url:'/live/delLive'+transSer,
    method:'delete',
    params:{
      liveId
    },
  })
}
//获取视频列表
export function getVideoList(keywords,currentPage,pageSize,hasAuth){
  return request({
    url:'/video/preachVideoList'+transSer,
    params:{
      keywords,currentPage,pageSize,hasAuth
    },
  })
}
//删除视频
export function delVideo(videoId){
  return request({
    url:'/video/delPreachVideo'+transSer,
    method:'delete',
    params:{
      videoId
    },
  })
}
//审核视频
export function auditVideo(videoId,res){
  return request({
    url:'/video/auditPreachVideo'+transSer,
    method:'put',
    params:{
      videoId,res
    },
  })
}
//删除评论
export function getOrginCompany(companyName){
  return request({
    url:'/company/getOrginCompany'+companyJobSer,
    method:'delete',
    params:{
      companyName
    },
  })
}


//删除评论
export function noPassUser(companyName){
  return request({
    url:'/user/noPassUser'+userSer,
    method:'delete',
    params:{
      companyName
    },
  })
}
//删除评论
export function delComment(commentId){
  return request({
    url:'/comment/delComment'+comSer,
    method:'delete',
    params:{
      commentId
    },
  })
}

//获取评论
export function nestComments(articleTitle){
  return request({
    url:'/comment/nestComment'+comSer,
    params:{
      articleTitle
    }
  })
}
//获取评论
export function commentList(keywords,currentPage,pageSize){
  return request({
    url:'/comment/commentList'+comSer,
    params:{
      keywords,currentPage,pageSize
    },
  })
}
//删除文章
export function delArticle(articleId){
  return request({
    url:'/article/delArticle'+comSer,
    method:'delete',
    params:{
      articleId
    },
  })
}
//获取文章
export function getArticleList(keywords,currentPage,pageSize,hasAuth){
  return request({
    url:'/article/articleList'+comSer,
    params:{
      keywords,currentPage,pageSize,hasAuth
    },
  })
}

//获取用户信息
export function getUserDetail(userName){
  return request({
    url:'/user/userDetail'+userSer,
    params:{
      userName
    },
  })
}

//审核企业
export function auditCompany(companyId,res){
  return request({
    url:'/company/auditCompany'+companyJobSer,
    params:{
      companyId, res
    },
  })
}
//认证企业用户
export function auditCompanyUser(userId,res){
  return request({
    url:'/user/auditCompanyUser'+userSer,
    params:{
      userId, res
    },
  })
}

//文章审核
export function auditArticle(articleId,res){
  return request({
    url:'/article/auditArticle'+comSer,
    params:{
      articleId, res
    },
  })
}

//获取资讯
export function getNewsList(keywords,currentPage,pageSize,filter){
  return request({
    url:'/news/newsList'+comSer,
    params:{
      keywords,currentPage,pageSize,filter
    },
  })
}

//删除资讯
export function delnews(newsId){
  return request({
    url:'/news/newsList'+comSer,
    params:{
      newsId
    },
  })
}
//上架下架资讯
export function shelveNews(newsId){
  return request({
    url:'/news/shelveNews'+comSer,
    method:'put',
    params:{
      newsId
    },
  })
}


export function getDashboard(){
  return request({
    url:'/admin/dashBoard'+userSer,
    method:'get'
  })
}
